package com.vshop.controller.alast.single;


import com.vshop.config.dto.ResultDataDto;
import com.vshop.entity.alast.single.autorenewal.cancel.request.RequestCancelAutoRenewalRecord;
import com.vshop.entity.alast.single.autorenewal.cancel.response.ResponseCancelAutoRenewalRecord;
import com.vshop.entity.alast.single.autorenewal.query.request.RequestQueryAutoRenewalRecord;
import com.vshop.entity.alast.single.autorenewal.query.response.ResponseQueryAutoRenewalRecord;
import com.vshop.entity.alast.single.autorenewal.reasonforcancel.request.RequestReasonForCancel;
import com.vshop.entity.alast.single.clickgiftbox.request.RequestClickGiftBox;
import com.vshop.entity.alast.single.order.request.RequestSingleOrder;
import com.vshop.entity.alast.single.order.response.ResponseSingleOrder;
import com.vshop.entity.alast.single.querydata.request.RequestQueryData;
import com.vshop.entity.alast.single.querydata.response.ResponseQueryData;
import com.vshop.entity.alast.single.queryorder.request.RequestSingleQueryOrder;
import com.vshop.entity.alast.single.queryorder.response.ResponseSingleQueryOrder;
import com.vshop.entity.alast.single.queryordersbystatus.request.RequestQueryOrdersByStatus;
import com.vshop.entity.alast.single.queryordersbystatus.response.ResponseQueryOrdersByStatus;
import com.vshop.entity.alast.single.serviceplan.request.RequestSingleServicePlanPage;
import com.vshop.entity.alast.single.serviceplan.response.ResponseSingleServicePlanPage;
import com.vshop.entity.alast.single.transactionhistory.request.RequestMyTransactionHistory;
import com.vshop.entity.alast.single.transactionhistory.response.ResponseMyTransactionHistory;
import com.vshop.entity.alast.single.verify.request.RequestSingleVerify;
import com.vshop.entity.alast.single.verify.response.ResponseSingleVerify;
import com.vshop.service.alast.LogicProcessesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Single模式所有接口
 * 包含：验证卡片，套餐列表，订购下单
 *
 * @author lm
 * @date 2020/6/8 14:54
 */
@RestController
@Api(value = "Single模式所有接口")
public class SingleDeviceController {

    @Autowired
    LogicProcessesService singleService;

    /**
     * Single模式卡片验证接口：
     * 1，验证卡片的有效性。
     * 2，验证卡片企业归属。
     * 3，验证卡片是否在除“废旧回收期”和“内部库存期”内。
     * 4，验证卡片归属企业的方案
     * <p>
     * 返回格式是：{"data":{},"message":"string","operateCode":"string"},ResponseSingleVerify是data部分
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "singleVerify", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "Single模式：验证卡片接口", response = ResponseSingleVerify.class)
    public ResultDataDto singleVerify(@ApiParam @RequestBody RequestSingleVerify request) {
        return singleService.singleVerify(request);
    }

    /**
     * Single模式：套餐列表页面接口：
     * 1，当前企业卡片可购套餐允许展示re.showStatus='1'；
     * 2，当前企业上架的套餐中存在第1步中的套餐编码p.packageCode = re.packageCode AND p.servicePlanStatus = '2'
     * 3, 当前请求的语言作为一个参数，如果一个企业某个语言的套餐上架好几个也是允许的
     * <p>
     * 返回格式是：{"data":{},"message":"string","operateCode":"string"},ResponsePartnerServicePlan是data部分
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "singleServicePlanPage", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "Single模式：套餐列表页面接口", response = ResponseSingleServicePlanPage.class)
    public ResultDataDto singleServicePlanPage(@ApiParam @RequestBody RequestSingleServicePlanPage request) {
        return singleService.singleServicePlanPage(request);
    }

    /**
     * Single模式：查询正在使用，未启用的订单：
     * <p>
     * 返回格式是：{"data":{},"message":"string","operateCode":"string"},ResponseSingleQueryOrder是data部分
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "singleQueryOrder", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "Single模式：查询正在使用，未启用的订单", response = ResponseSingleQueryOrder.class)
    public ResultDataDto singleQueryOrder(@ApiParam @RequestBody RequestSingleQueryOrder request) {
        return singleService.singleQueryOrder(request);
    }

    /**
     * Single模式：下单接口：
     * <p>
     * 返回格式是：{"data":{},"message":"string","operateCode":"string"},ResponseSingleOrder是data部分
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "singleOrder", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "Single模式：下单接口", response = ResponseSingleOrder.class)
    public ResultDataDto singleOrder(@ApiParam @RequestBody RequestSingleOrder request) {
        return singleService.singleOrder(request);
    }

    /**
     * 方案一：流量查询接口
     * <p>
     * 返回格式是：{"data":{},"message":"string","operateCode":"string"},ResponseQueryData是data部分
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "queryData", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "方案一：查询流量", response = ResponseQueryData.class)
    public ResultDataDto queryData(@ApiParam @RequestBody RequestQueryData request) {
        return singleService.queryData(request);
    }

    /**
     * Single模式：查询自动续费记录
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "queryAutoRenewalRecord", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "Single模式：查询自动续费记录", response = ResponseQueryAutoRenewalRecord.class)
    public ResultDataDto queryAutoRenewalRecord(@ApiParam @RequestBody RequestQueryAutoRenewalRecord request) {
        return singleService.queryAutoRenewalRecord(request);
    }

    /**
     * Single模式：取消自动续费的原因
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "reasonForCancel", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "Single模式：取消自动续费的原因")
    public ResultDataDto reasonForCancel(@ApiParam @RequestBody RequestReasonForCancel request) {
        return singleService.reasonForCancel(request);
    }

    /**
     * Single模式：：取消自动续费记录
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "cancelAutoRenewalRecord", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "Single模式：取消自动续费记录", response = ResponseCancelAutoRenewalRecord.class)
    public ResultDataDto cancelAutoRenewalRecord(@ApiParam @RequestBody RequestCancelAutoRenewalRecord request) {
        return singleService.cancelAutoRenewalRecord(request);
    }

    /**
     * Single模式：：用户点击礼物盒
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "clickGiftBox", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "Single模式：用户点击礼物盒")
    public ResultDataDto clickGiftBox(@ApiParam @RequestBody RequestClickGiftBox request) {
        return singleService.clickGiftBox(request);
    }

    /**
     * Single模式：：用户"My Order" 获取卡片所有的购买交易记录
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "myTransactionHistory", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "Single模式：我的交易记录", response = ResponseMyTransactionHistory.class)
    public ResultDataDto myTransactionHistory(@ApiParam @RequestBody RequestMyTransactionHistory request) {
        return singleService.myTransactionHistory(request);
    }

    /**
     * Single模式：：按不同状态（2-正在使用；1-未生效；3-已结束）查询订单
     *
     * @param request
     * @return
     */
    @CrossOrigin
    @PostMapping(value = "queryOrdersByStatus", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "Single模式：按不同状态（2-正在使用；1-未生效；3-已失效）查询订单", response = ResponseQueryOrdersByStatus.class)
    public ResultDataDto queryOrdersByStatus(@ApiParam @RequestBody RequestQueryOrdersByStatus request) {
        return singleService.queryOrdersByStatus(request);
    }
}
